import os
import re
import shutil

if __name__ == '__main__':
    videoDir = "/Users/victoryang/娱乐/动态壁纸/video"
    imgDir = "/Users/victoryang/娱乐/动态壁纸/images"
    videoList = os.listdir(videoDir)
    convert = lambda text: int(text) if text.isdigit() else text.lower()
    videoList.sort(key=lambda x: [convert(c) for c in re.split('([0-9]+)', x)])
    for file in videoList:
        if not file.startswith('.'):
            file_ = str(file)[:-4]
            print(file_)
            imgName = file_ + ".jpg"
            imgFile = videoDir + "/" + imgName
            try:
                shutil.copy(imgDir + "/" + imgName, imgFile)
            except:
                print("error" + imgName)
